/******************************************************************************
 * (C) Copyright 2020 Atech-Automotive
 * FILE NAME:    app_sci1_Itf.c
 * DESCRIPTION:
 * 
 * DATE BEGUN:   2020/09/18
 * BY:           yong.ding
 * PRODUCT NAME:
 * APPLICATION:
 * TARGET H/W:
 * DOC REF:
 *****************************************************************************
 */

/*****************************************************************************
** #include 
*****************************************************************************/
#include <string.h>
#include "app_sci1_Itf.h"
#include "drv_SCI.h"
#include  "msg_sciApi.h"
#include  "msg_canApi.h"
#define CAN_RX_USE_TEST  1
#define CAN_RX_USE_X70  0

/*****************************************************************************
** function prototypes
*****************************************************************************/

/****************************************************************************/
BOOL app_sci1ItfGetIGN(void)
{
    //return hwa_inputs_u8_getInput(SI_PAD8_IN);
    return TRUE;
}


BOOL app_sci1ItfSendFrame(UINT8 id,BOOL sub_exist,UINT8 sub_id,UINT8 txData_len,UINT8* p_u8_txData)
{
	return drv_sci1SendFrame(id,sub_exist,sub_id,txData_len,p_u8_txData);
}

BOOL app_sci1ItfGetMessage(UINT8 *u8_id,UINT8 *u8_sub_id, UINT8 *u8_length, UINT8 *p_u8_txData)
{
    return drv_sci1_v_getMessage(u8_id,u8_sub_id,u8_length,p_u8_txData);
}

UINT8 app_sci1ItfGetRxMessageCount(void)
{
    return drv_sci1_u8_getRxMessageCount();  
}

void app_sci1ItfUpdataTxMsgs(void)
{ 
 UINT8 u8_temp=0; 
 UINT16 u16_temp=0;
 UINT32 u32_temp=0;
//   c_u16_wr(&CanMsg4E1_Tx, 38, 10, 0x1ff);
//   c_u8_wr(&CanMsg531_Tx, 0, 8, 0x30);
//   c_bool_wr(&CanMsg531_Tx,8,1,temp);
//  c_bool_wr(&CanMsg531_Tx,15,1,temp);
#if	CAN_RX_USE_TEST

	u8_temp = c_u8_rd(&CanMsg123_Rx,0,2);
	if(u8_temp == 0)
	{
		s_u8_wr(&SciMsg1C_Tx, 0,1,u8_temp);//biao shi xi tong dian yuan guan bi

	}
	else if(u8_temp == 1)
	{
		s_u8_wr(&SciMsg1C_Tx, 0,1,1);//biao shi xi tong dian yuan da kai
	}
	else
	{
		s_u8_wr(&SciMsg08_Tx, 0,8,12);//qi che da huo
	}

	

	u8_temp = c_bool_rd(&CanMsg123_Rx,2,1);
	if(u8_temp == 0)
	{
		s_u8_wr(&SciMsg08_Tx, 0,8,5);
	}
	else if(u8_temp == 1)
	{
		s_u8_wr(&SciMsg08_Tx, 0,8,4);
	}

	u8_temp = c_bool_rd(&CanMsg123_Rx,3,1);
	if(u8_temp == 0)
	{
		s_u8_wr(&SciMsg08_Tx, 0,8,3);
	}
	else if(u8_temp == 1)
	{
		s_u8_wr(&SciMsg08_Tx, 0,8,2);
	}

	u8_temp = c_bool_rd(&CanMsg123_Rx,4,1);
	if(u8_temp == 0)
	{
		s_u8_wr(&SciMsg08_Tx, 0,8,1);
	}
	else if(u8_temp == 1)
	{
		s_u8_wr(&SciMsg08_Tx, 0,8,0);
	}

	
	u16_temp = c_u16_rd(&CanMsg123_Rx,19,13);
	u16_temp = ((UINT32)u16_temp * 63)/1000;
	s_u8_wr(&SciMsg08_Tx, 0,8,u16_temp);

#endif
	
}


/*for other interface*/

  
/*****************************************************************************
** End File
*****************************************************************************/
